// diff with file://./rxjs-case-combineLatestWith.ts
import { of } from "rxjs";
import { withLatestFrom } from "rxjs/operators";

const source1$ = of("A", "B", "C");
const source2$ = of(1, 2, 3);

source1$.pipe(withLatestFrom(source2$)).subscribe(([val1, val2]) => {
  console.log(`WithLatestFrom: ${val1}, ${val2}`);
});

// 输出：
// WithLatestFrom: A, 3
// WithLatestFrom: B, 3
// WithLatestFrom: C, 3
// 解释：source1$ 每次发出值时，都会带上 source2$ 的最新值（即3，因为 source2$ 已经同步发出了所有值，最后是3）
